Refactor CopilotClient.create_session() to have parameters#587
Open
brettcannon wants to merge 3 commits intogithub:mainfrom
Open
Refactor CopilotClient.create_session() to have parameters#587brettcannon wants to merge 3 commits intogithub:mainfrom
CopilotClient.create_session() to have parameters#587brettcannon wants to merge 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Python SDK CopilotClient.create_session() API from a single SessionConfig dict to explicit parameters (with keyword-only options), and updates all Python examples/tests/docs/scenarios to use the new call signature.
Changes:
- Refactor
python/copilot/client.py:create_session()to accepton_permission_request, optionalmodel, plus keyword-only session options; removeSessionConfigfrom Python types/exports. - Update Python tests, E2E tests, samples, and scenario scripts to call
create_session(...)with the new signature. - Update Python and cross-repo documentation snippets to match the new API.
Reviewed changes
Copilot reviewed 64 out of 64 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/scenarios/transport/tcp/python/main.py | Update create_session call to new positional args + PermissionHandler. |
| test/scenarios/transport/stdio/python/main.py | Update create_session call to new signature. |
| test/scenarios/transport/reconnect/python/main.py | Update both session creations to new signature. |
| test/scenarios/tools/virtual-filesystem/python/main.py | Switch from config dict to positional permission handler + keyword options. |
| test/scenarios/tools/tool-filtering/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/tools/skills/python/main.py | Switch to new signature for skills scenario. |
| test/scenarios/tools/no-tools/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/tools/mcp-servers/python/main.py | Refactor session config building to **kwargs + new signature. |
| test/scenarios/tools/custom-agents/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/sessions/streaming/python/main.py | Switch to new signature with streaming=True. |
| test/scenarios/sessions/session-resume/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/sessions/infinite-sessions/python/main.py | Switch to new signature and keyword-only infinite_sessions. |
| test/scenarios/sessions/concurrent-sessions/python/main.py | Switch both concurrent session creations to new signature. |
| test/scenarios/prompts/system-message/python/main.py | Switch to new signature and keyword-only system_message. |
| test/scenarios/prompts/reasoning-effort/python/main.py | Switch to new signature and keyword-only reasoning_effort. |
| test/scenarios/prompts/attachments/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/modes/minimal/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/modes/default/python/main.py | Switch to new signature. |
| test/scenarios/callbacks/user-input/python/main.py | Switch to new signature and keyword-only on_user_input_request/hooks. |
| test/scenarios/callbacks/permissions/python/main.py | Switch to new signature and keyword-only hooks. |
| test/scenarios/callbacks/hooks/python/main.py | Switch to new signature and keyword-only hooks. |
| test/scenarios/bundling/fully-bundled/python/main.py | Switch to new signature. |
| test/scenarios/bundling/container-proxy/python/main.py | Switch to new signature. |
| test/scenarios/bundling/app-direct-server/python/main.py | Switch to new signature. |
| test/scenarios/bundling/app-backend-to-server/python/main.py | Switch to new signature for backend service example. |
| test/scenarios/auth/gh-app/python/main.py | Switch to new signature. |
| test/scenarios/auth/byok-openai/python/main.py | Switch to new signature and keyword-only provider. |
| test/scenarios/auth/byok-ollama/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/auth/byok-azure/python/main.py | Switch to new signature and keyword-only options. |
| test/scenarios/auth/byok-anthropic/python/main.py | Switch to new signature and keyword-only options. |
| python/test_client.py | Update unit tests for new signature and updated failure mode when missing args. |
| python/samples/chat.py | Update sample to new create_session signature. |
| python/e2e/test_tools.py | Update E2E tool tests to new signature. |
| python/e2e/test_skills.py | Update E2E skills tests to new signature. |
| python/e2e/test_session.py | Update E2E session tests to new signature. |
| python/e2e/test_rpc.py | Update E2E RPC tests to new signature. |
| python/e2e/test_permissions.py | Update E2E permission tests to new signature. |
| python/e2e/test_mcp_and_agents.py | Update E2E MCP/agents tests to new signature. |
| python/e2e/test_hooks.py | Update E2E hooks tests to new signature. |
| python/e2e/test_compaction.py | Update E2E compaction tests to new signature. |
| python/e2e/test_client.py | Update E2E client tests to new signature. |
| python/e2e/test_ask_user.py | Update E2E ask-user tests to new signature. |
| python/e2e/test_agent_and_compact_rpc.py | Update agent/compaction RPC E2E tests to new signature. |
| python/copilot/types.py | Remove SessionConfig TypedDict (API surface cleanup). |
| python/copilot/client.py | Refactor create_session API to explicit parameters; update docs in docstring. |
| python/copilot/init.py | Stop exporting SessionConfig from the Python package. |
| python/README.md | Update public docs for new create_session parameters and examples. |
| docs/mcp/overview.md | Update Python MCP server example to new signature. |
| docs/hooks/user-prompt-submitted.md | Update Python snippet to pass required permission handler. |
| docs/hooks/session-lifecycle.md | Update Python snippets to pass required permission handler. |
| docs/hooks/pre-tool-use.md | Update Python snippet to pass required permission handler. |
| docs/hooks/post-tool-use.md | Update Python snippet to pass required permission handler. |
| docs/hooks/overview.md | Update Python hooks quickstart to new signature. |
| docs/hooks/error-handling.md | Update Python snippet to pass required permission handler. |
| docs/guides/skills.md | Update Python skills example to new signature. |
| docs/guides/setup/local-cli.md | Update Python setup example to new signature. |
| docs/guides/setup/github-oauth.md | Update Python OAuth example to new signature. |
| docs/guides/setup/byok.md | Update Python BYOK example to new signature. |
| docs/guides/setup/bundled-cli.md | Update Python bundled CLI example to new signature. |
| docs/guides/setup/backend-services.md | Update Python backend service example to new signature. |
| docs/guides/setup/azure-managed-identity.md | Update Python managed identity guide to new signature and dict-based provider config. |
| docs/guides/session-persistence.md | Update Python session persistence example to new signature. |
| docs/getting-started.md | Update Python getting-started examples to new signature. |
| docs/auth/byok.md | Update Python BYOK auth doc example to new signature. |
- Add validation for on_permission_request in create_session to fail fast when handler is missing/invalid - Fix lambda signatures to accept two args (request, invocation) in test scenario and docs - Fix permissionDecision key to use camelCase in pre_tool_use hook Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.